package com.jiyun.order.controller;


import com.jiyun.order.service.IGoodsInfoService;
import com.jiyun.orders.pojo.GoodsInfo;
import com.jiyun.orders.vo.ResultVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 货物信息表 前端控制器
 * </p>
 *
 * @author 1823.
 * @since 2025-02-12
 */
@RestController
@RequestMapping("/goods-info")
public class GoodsInfoController {

    @Autowired
    private IGoodsInfoService goodsInfoService;

    @Operation(summary = "获取所有货物信息")
    @RequestMapping("/getAllGoodsInfo")
    public List<GoodsInfo> getAllGoodsInfo(){
        return goodsInfoService.list();
    }


//    @Operation(summary = "添加货物信息")
//    @RequestMapping("/addGoodsInfo")
//    public ResultVo addGoodsInfo(@RequestBody List<GoodsInfo> goodsInfoList){
//       return  goodsInfoService.addGoodsInfo(goodsInfoList);
//    }

    @Operation(summary = "修改货物信息")
    @PostMapping("/updateGoodsInfo")
    public ResultVo updateGoodsInfo(@RequestBody GoodsInfo goodsInfo){
        return ResultVo.ok(goodsInfoService.updateById(goodsInfo));
    }

    @Operation(summary = "删除货物信息")
    @RequestMapping("deleteGoodsInfo/{id}")
    public ResultVo deleteGoodsInfo(@PathVariable Integer id){
        return ResultVo.ok(goodsInfoService.removeById(id));
    }

    @Operation(summary = "货物详情")
    @RequestMapping("/getGoodsInfoByOrderId/{id}")
    public ResultVo getGoodsInfo(@PathVariable Integer id){
        return ResultVo.ok(goodsInfoService.getById(id));
    }
}
